﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using WCFServiceWebRole1.Services;
using GlobalObjects;
using WCFServiceWebRole1.DataObjects;
using System.ServiceModel;
using System.Diagnostics;

namespace WCFServiceWebRole1_Tests
{
     [TestClass]
    public class UsersTests
    {
        public static User_Rest_Host UserRestHost { get; set; }
        public static Iusers UserRest { get; set; }

         [ClassInitialize]
        public static void classInitialization(TestContext testcontext)
        {
            //Debug.Print("Starting Host");
            //UserRestHost = new User_Rest_Host().StartHost();
            //UserRest = UserRestHost.GetProxy();
        }
         [TestMethod]
         public void addUser_notvalid_all_null()
         {
         }
        // }
        // [TestMethod]
        //public void CheckWebServiceHost()
        //{


        //    ChannelFactory<Iusers> fac = new ChannelFactory<Iusers>("local");
        //    var prox = fac.CreateChannel();

        //    using (prox as IDisposable)
        //    {
        //        //Creating request message
        //        User req = new User()
        //        {
        //            Country = "",
        //            Email = "",
        //            FirstName = "",
        //            LastName = "",
        //            Organisation = "",
        //            Password = "",
        //            Purpose = "",
        //            Title = "",
        //            Username = ""
        //        };
        //        //Passing request to service
        //        UserDetailsResponse response = prox.addUser(req);

        //        //Checking expected with actual values
        //        Assert.IsNull(response);
        //    }



         ////    var html = new Uri(UserRestHost.BaseAddress,"/")
         //   var devices = UserRest.getUserByUserId("69");
         //   Debug.Print("User Name"+ devices.response.FirstName);
         //   //foreach (var dev in devices.Public)
         //   //{

         //   //    Debug.Print(dev.Name);
         //   //}
         //   Assert.Equals(devices.response.FirstName, "123");

       // }

             [ClassCleanup]
        public static void classCleanup()
        {
            Trace.WriteLine("Stopping Host");
            UserRestHost.StopHost();
        }


        //#region addUser
         
        ////[TestMethod]
        ////public void addUser_notvalid_username_null()
        ////{
        ////    user servobj = new user();

        ////    //Creating request message
        ////    User req = new User()
        ////    {
        ////        Country = "United Kingdom",
        ////        Email = "ucabra0@ucl.ac.uk",
        ////        FirstName = "Ayyappan",
        ////        LastName = "Ramamuniappa",
        ////        Organisation = "UCL",
        ////        Password = "Password",
        ////        Purpose = "Education",
        ////        Title = "Mr",
        ////        Username = ""
        ////    };

        ////    //Passing request to service

        ////    UserDetailsResponse response = servobj.addUser(req);

        ////    //Checking expected with actual values
        ////    Assert.AreEqual(0, response.response.Id);

        ////}
        ////[TestMethod]
        ////public void addUser_notvalid_password_null()
        ////{
        ////    user servobj = new user();

        ////    //Creating request message
        ////    User req = new User()
        ////    {
        ////        Country = "United Kingdom",
        ////        Email = "ucabra0@ucl.ac.uk",
        ////        FirstName = "Ayyappan",
        ////        LastName = "Ramamuniappa",
        ////        Organisation = "UCL",
        ////        Password = "",
        ////        Purpose = "Education",
        ////        Title = "Mr",
        ////        Username = "appy"
        ////    };

        ////    //Passing request to service

        ////    UserDetailsResponse response = servobj.addUser(req);

        ////    //Checking expected with actual values
        ////    Assert.AreEqual(0, response.response.Id);

        ////}
        ////[TestMethod]
        ////public void addUser_notvalid_username_not_present()
        ////{
        ////    user servobj = new user();

        ////    //Creating request message
        ////    User req = new User()
        ////    {
        ////        Country = "United Kingdom",
        ////        Email = "ucabra0@ucl.ac.uk",
        ////        FirstName = "Ayyappan",
        ////        LastName = "Ramamuniappa",
        ////        Organisation = "UCL",
        ////        Password = "",
        ////        Purpose = "Education",
        ////        Title = "Mr"

        ////    };

        ////    //Passing request to service

        ////    UserDetailsResponse response = servobj.addUser(req);

        ////    //Checking expected with actual values
        ////    Assert.AreEqual(0, response.response.Id);

        ////}
        ////[TestMethod]
        ////public void addUser_notvalid_password_not_present()
        ////{
        ////    user servobj = new user();

        ////    //Creating request message
        ////    User req = new User()
        ////    {
        ////        Country = "United Kingdom",
        ////        Email = "ucabra0@ucl.ac.uk",
        ////        FirstName = "Ayyappan",
        ////        LastName = "Ramamuniappa",
        ////        Organisation = "UCL",

        ////        Purpose = "Education",
        ////        Title = "Mr",
        ////        Username = "appy"
        ////    };

        ////    //Passing request to service

        ////    UserDetailsResponse response = servobj.addUser(req);

        ////    //Checking expected with actual values
        ////    Assert.AreEqual(0, response.response.Id);

        ////}
        ////[TestMethod]
        ////public void addUser_notvalid_others_not_present()
        ////{
        ////    user servobj = new user();

        ////    //Creating request message
        ////    User req = new User()
        ////    {
        ////        Country = "United Kingdom",
        ////        Email = "ucabra0@ucl.ac.uk",

        ////        Organisation = "UCL",
        ////        Password = "Password",
        ////        Purpose = "Education",
        ////        Title = "Mr",
        ////        Username = "appy"
        ////    };

        ////    //Passing request to service

        ////    UserDetailsResponse response = servobj.addUser(req);

        ////    //Checking expected with actual values
        ////    Assert.AreEqual(0, response.response.Id);

        ////}
        //////[TestMethod]
        //////public void addUser_notvalid_password_null()
        //////{
        //////    user servobj = new user();

        //////    //Creating request message
        //////    User req = new User()
        //////    {
        //////        Country = "United Kingdom",
        //////        Email = "ucabra0@ucl.ac.uk",
        //////        FirstName = "Ayyappan",
        //////        LastName = "Ramamuniappa",
        //////        Organisation = "UCL",
        //////        Password = "Password",
        //////        Purpose = "Education",
        //////        Title = "Mr",
        //////        Username = "appy"
        //////    };

        //////    //Passing request to service

        //////    UserDetailsResponse response = servobj.addUser(req);

        //////    //Checking expected with actual values
        //////    Assert.AreEqual(0, response.response.Id);

        //////}
        ////[TestMethod]
        ////public void addUser_valid()
        ////{
        ////    user servobj = new user();

        ////    //Creating request message
        ////    User req = new User()
        ////    {
        ////        Country = "United Kingdom",
        ////        Email = "ucabra0@ucl.ac.uk",
        ////        FirstName = "Ayyappan",
        ////        LastName = "Ramamuniappa",
        ////        Organisation = "UCL",
        ////        Password = "Password",
        ////        Purpose = "Education",
        ////        Title = "Mr",
        ////        Username = "appy"
        ////    };

        ////    //Passing request to service

        ////    UserDetailsResponse response = servobj.addUser(req);

        ////    //Checking expected with actual values
        ////    Assert.AreNotEqual(0, response.response.Id);

        ////}
        //#endregion
    }
}
